﻿using System;
using System.Collections.Generic;
using WAD.WEB.AppCode;
using QD.Data.Json;
using System.Text;
using WAD.DAL;
using WAD.Model;

namespace WAD.WEB.Client2.Ajax
{
    /// <summary>
    /// Config 的摘要说明
    /// </summary>
    public partial class Config : AjaxBase
    {
        public override void AjaxMethodDispatch(String identity)
        {
            switch (identity)
            {
                case "load": this.Load(); break;
                case "wxconfig": this.WXConfig(); break;
            }
        }
        /// <summary>
        /// APP全局参数
        /// </summary>
        [QD.Web.Ajax.AjaxMethod]
        public void Load()
        {
            StringBuilder json = new StringBuilder();
            json.Append("{");
            
            string domain = WJXConfig.Path.URL;
            json.Append("\"code\":0,\"msg\":\"成功\"");

            //头部频道导航
            PageData pg = DaoChannel.GetList(1, 20, true);
            json.Append(",\"channel\":[");
            if (pg.table != null)
            {
                for (int i = 0; i < pg.table.Rows.Count; i++)
                {
                    
                }
            }
            json.Append("]");
            
            
            //首页底部导航
            json.Append(",\"footbar\":[");
            json.Append("{\"name\":\"发现\",\"link\":\"" + domain + "/client/index_app.html\"}");
            json.Append(",{\"name\":\"发布\",\"link\":\"" + domain + "/client/publish.html\"}");
            json.Append(",{\"name\":\"推广\",\"link\":\"" + domain + "/client/Makesh_1.html\"}");
            json.Append(",{\"name\":\"我的\",\"link\":\"" + domain + "/client/personal.html\"}");
            json.Append("]");

            

            json.Append("}");

            Echo(json.ToString());
        }

        /// <summary>
        /// 微信分享、提现参数
        /// </summary>
        [QD.Web.Ajax.AjaxMethod]
        public void WXConfig()
        {
            JsonBuilder json = new JsonBuilder();
            //登录、提现参数
            json.Append("appid", WJXConfig.WeixinOpenConfig.APPID);
            json.Append("key", WJXConfig.WeixinOpenConfig.AppSecret);

            //分享参数
            json.Append("appid_shared", WJXConfig.WeixinOpenConfig.APPID_Shared);
            json.Append("key_shared", WJXConfig.WeixinOpenConfig.AppSecret_Shared);

            JsonResultAppend(0, "", json);
        }

        private void Echo(string s)
        {
            Context.Response.Clear();
            Context.Response.Write(s);
            Context.Response.End();
        }
    }
}